<?php
/*
	[UCenter Home] (C) 2007-2008 Comsenz Inc.
	$Id: cp_follow.php 11974 2009-04-22 07:29:40Z lrb $
*/

if(!defined('IN_UCHOME')) {
	exit('Access Denied');
}

$op = empty($_GET['op'])?'':$_GET['op'];

$supe_uid=$_SGLOBAL['supe_uid'];

include_once(S_ROOT.'./source/function_follow.php');

$uid = empty($_REQUEST['uid'])?0:intval($_REQUEST['uid']);


if($op=='add'){
    
    if($uid==0){rtjson(cplang('follow_nouser'));}
 
    $status = getfollowstatus($supe_uid, $uid);
    
	if($status == 1) {
		rtjson(cplang('follow_over'));
	}
    if($uid == $supe_uid) {
		rtjson(cplang('follow_fail_me'));
	}
    
    
    $tospace=getspace($uid);
    
    if(empty($tospace)) {
		rtjson(cplang('follow_nouser'));
	}
    
    $fdata=array(
        'uid'=>$supe_uid,
        'username'=>$space['username'],
        'fuid'=>$uid,
        'fusername'=>$tospace['username'],
        'status'=>1,
        'dateline' => $_SGLOBAL['timestamp']
    );
    
    inserttable('follow',$fdata);
    

    rtjson('<em class="ico_fo"></em>已关注,<a class="ulinea" href="javascript:void(0)" onclick="followdel(this,'.$uid.')">取消</a>',0);


}elseif($op=='del'){

    if($uid==0){rtjson(cplang('follow_nouser'));}

    $status = getfollowstatus($supe_uid, $uid);
    
	if($status == 1) {
        $_SGLOBAL['db']->query("delete  from ".tname('follow')." where uid='".$supe_uid."' and fuid='$uid'");
    }else{
        rtjson(cplang('follow_cancel_over'));
    }

    rtjson('<a class="ulinea" href="javascript:void(0)" onclick="follow(this,'.$uid.')">关注</a>',0);


}elseif($op=='followme'){//粉丝列表
    
    if($uid==0){$uid=$supe_uid;}
    
    list($list,$count,$multi)=followlist($uid,'f',$op);
   
   $followname=cplang($op);

}else{//关注列表if($op=='follow')
    $op='follow';
    if($uid==0){$uid=$supe_uid;}
    
    $followname=cplang($op);
    
   list($list,$count,$multi)=followlist($uid,'',$op);
    
}


include_once template("cp_follow");


?>